<template>

  <el-table :data="list">
    <el-table-column
      type="index"
      label="#"
      width="width"
    />
    <el-table-column
      prop="title"
      label="标题"
      width="width"
    />
    <el-table-column
      prop="des"
      label="链接描述"
      width="width"
    />
    <el-table-column
      label="链接类型"
      width="width"
    >
      <template slot-scope="{row}">
        <el-button type="success" plain size="small" class="el-icon-tickets">{{ row.type === '1'? '文字链接': '图片链接' }}</el-button>
      </template>
    </el-table-column>
    <el-table-column
      prop="url"
      label="链接地址"
      width="width"
    />
    <el-table-column

      label="操作"
      width="width"
    >
      <template slot-scope="{row}">
        <el-button type="success" plain @click="getlinkInfoApi(row.id)">编辑</el-button>
        <el-button type="danger" plain @click="dellinkInfoApi(row.id)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

</template>

<script>
import { dellinkInfoApi, getlinkInfoApi } from '@/api/adv_link'
import bus from '@/components/bus'
export default {
  name: 'HypertextTink',
  props: {
    list: {
      type: Array,
      default: () => {}
    }

  },
  data() {
    return {
      formData: {
        type: '',
        title: '', // 文字链接标题
        des: '', // 链接描述
        url: '', // 链接地址
        img: '' // 图片链接
      }
    }
  },
  mounted() {
    // 接受传来的个人信息
    bus.$on('data', data => {
      this.formData = data
      this.dialogisShow = true
    })
  },
  methods: {
    // 删除
    async dellinkInfoApi(id) {
      await this.$confirm('确让删除吗？')
      await dellinkInfoApi({ id })
      this.$message.success('删除成功')
      this.$emit('getlinkListApi')
    },
    // 编辑
    async   getlinkInfoApi(id) {
      const res = await getlinkInfoApi({ id })
      bus.$emit('data', res)
    }
  }
}
</script>

<style>

</style>
